﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GzipManagerPro.IO
{
    
    partial class Folder
    {
        internal override bool WriteTo(System.IO.Stream stream, Archive archive)
        {
            archive.OnArchiveMessage(new ArchiveMessageEventArgs(archive.TotalProgress, archive.CurrentProgress, "Writing folder {0}...", this.Name));
            this.Files.ForEach(f =>
            {
                archive.OnArchiveMessage(new ArchiveMessageEventArgs(archive.TotalProgress, archive.CurrentProgress, "Writing file {0}...", f.Name));
                f.WriteTo(stream, archive);
                archive.CurrentProgress++;
            });
            this.Folders.ForEach(f => f.WriteTo(stream, archive));
            return true;
        }

    }
}
